<!-- <!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title>每隔一秒种显示一个数</title>
</head>
<body>
    <div id="num">
        
    </div>
</body>
<script src="js/index.js"></script>
</html> -->

<!-- 闭包阻止事件冒泡 -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="zh-CN" /> 

<title></title>
<script language="JavaScript" type="text/javascript" src="js/jquery-3.1.0.js"></script>
<script>
   /* $(document).ready(function(){
        $("#div1").mousedown(function(event){
            // event.stopPropagation();
            return false;
        });
        $("#div2").mousedown(function(event){
            alert("trigger mousedown event of rootDiv");
        });
    });*/

function foo(x) { 
var tmp = 3; 
return function (y) { 
alert(x + y + tmp); 
x.memb = x.memb ? x.memb + 1 : 1; 
alert(x.memb); 
} 
} 
var age = new Number(2); 
var bar = foo(age); // bar 现在是一个引用了age的闭包 
bar(10); 
</script>
</head>
<body>
    <div id="rootDiv" style="position:relative;left:400px;top:200px;">
        <div>1.单击输入框，使输入框获取焦点：</div>
        <input id="input1" style="width:250px;" type="text"></input>
        <div id="div2">
            <div id="div1" style="width:200px;height:200px;background-color:red;"><br><br>2.然后再单击这里</div>
        </div>
    </div>
</body>
</html>